package cn.edu.zzuli.nothinglink.mapper;

import cn.edu.zzuli.nothinglink.entity.Students;
import cn.edu.zzuli.nothinglink.mapper.provider.StudentsProvider;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author suzyyy
 * @since 2021-04-08
 */
public interface StudentsMapper extends BaseMapper<Students> {

    @SelectProvider(type = StudentsProvider.class, method = "findByInfo")
    Students findStuByInfo(Map<String, Object> info);

    @Select("<script>SELECT * FROM students WHERE deleted = 0 AND belong_class_id in (" +
                "<foreach collection='classIds' item='item' index='index' separator=',' >" +
                    "#{item}" +
                "</foreach> )" +
            "</script>")
    List<Students> getStusWhenClassInList(@Param("classIds") Set<Integer> classIds);

    @Select("<script>SELECT * FROM students WHERE deleted = 0 AND students.stu_id in (" +
            "<foreach collection='stuIds' item='item' index='index' separator=',' >" +
                "#{item}" +
            "</foreach> )" +
            "</script>")
    List<Students> selectBatchId(@Param("stuIds") Set<Object> ids);
}
